package com.lanlan.config;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;

/**
 * 
 * @ClassName: DataSourceConfig
 * @Description: 数据源
 * @author XGJ
 * @date 2022-10-13 10:20:37
 */
@Configuration
public class DataSourceConfig {

    /**
     * 
     * @Title: userDataSource
     * @Description: user数据源
     * @return DataSource
     * @author XGJ
     * @date 2022-10-13 10:21:19
     */
    @Primary
    @Bean(name = "userDataSource", destroyMethod = "close", initMethod = "init")
    @ConfigurationProperties(prefix = "spring.datasource.user")
    public DataSource userDataSource() {
	return DruidDataSourceBuilder.create().build();
    }

    /**
     * 
     * @Title: vendorDataSource
     * @Description: vendor数据源
     * @return
     * @author XGJ
     * @date 2022-10-13 10:21:58
     */
    @Bean(name = "vendorDataSource", destroyMethod = "close", initMethod = "init")
    @ConfigurationProperties(prefix = "spring.datasource.vendor")
    public DataSource vendorDataSource() {
	return DruidDataSourceBuilder.create().build();
    }

}
